package vip.xiaonuo.vein.controller.vo;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import lombok.Data;
import lombok.NoArgsConstructor;
import vip.xiaonuo.facedoor.modular.memberfeatures.entity.MemberFeatures;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@Data
public class AddFeatureInfo {

    @JSONField(name = "add_feature_info")
    private List<AddFeatureInfoDTO> addFeatureInfo;

    @NoArgsConstructor
    @Data
    public static class AddFeatureInfoDTO {
        @JSONField(name = "user_uuid")
        private String userUuid;
        @JSONField(name = "palm_vein_feature_right")
        private String palmVeinFeatureRight;
        @JSONField(name = "palm_vein_feature_left")
        private String palmVeinFeatureLeft;
        @JSONField(name = "finger_print")
        private String fingerPrint;
        @JSONField(name = "iris")
        private String iris;
        @JSONField(name = "ic_card")
        private String icCard;
        @JSONField(name = "password")
        private String password;
    }

    public AddFeatureInfo(MemberFeatures feature){
        this.addFeatureInfo = new ArrayList<>();
        AddFeatureInfoDTO dto = new AddFeatureInfoDTO();
        dto.setUserUuid("1" + feature.getDwMemberUserId());
        Feature f;
        try{
            f = JSON.parseObject(feature.getValue(),Feature.class);
            dto.setPalmVeinFeatureLeft(f.getLeft());
            dto.setPalmVeinFeatureRight(f.getRight());
            addFeatureInfo.add(dto);
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
